/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.pac3.persistence.dao;

import edu.uoc.tdp.pac3.domain.Request;
import edu.uoc.tdp.pac3.domain.RequestType;
import java.util.List;
import edu.uoc.tdp.pac3.persistence.dao.impl.RequestDao;
import java.sql.Date;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Gerard
 */
public class RequestDaoTestCase {
    
    private static IRequestDao dao;

    @BeforeClass
    public static void setUpClass() throws Exception {
        dao = new RequestDao();
    }
    
    
    @Test
    public void test_retrieve_data(){
        List<Request> list = dao.findAll();
        for(Request request : list){
            System.out.println(request.getId());
        }
        assertEquals(3, list.size());
    }
    
      
    @Test
    public void test_findById(){
        Request request = dao.findById(1);
        assertNotNull(request);
    }
    
    @Test
    @Ignore
    public void test_insert(){
        Request request = new Request();
        request.setAreaId(1);
        request.setCreationDate(new Date(2011,1,1));
        request.setDescription("JUNIT");
        request.setRequestType(RequestType.NOTSOLVED);
        request.setUserId(1);
        assertTrue(dao.insert(request));
    }
    
    @Test
    public void test_update(){
        Request request = dao.findById(1);
        request.setDescription("DESC_JUNIT");
        assertTrue(dao.update(request));
    }
    
    @Test
    @Ignore
    public void test_delete(){
        Request area = dao.findById(4);
        assertNotNull(area);
        Boolean result = dao.delete(area);
        assertTrue(result);
    }
}
